using System;
using System.Collections.Generic;
using System.Text;

namespace NBusiness.Templates.Sql
{
    /// <summary>
    /// This is not used currently, it needs more work before it can be used.
    /// </summary>
    [Serializable]
    public class SqlScriptsOptions : SchemaUpdaterOptions
    {
        private string _serverName;
        public string ServerName
        {
            get { return this._serverName; }
            set { _serverName = value; }
        }
        private string _databaseName;
        public string DatabaseName
        {
            get { return this._databaseName; }
            set { this._databaseName = value; }
        }

        private bool _integratedSecurity = true;
        public bool IntegratedSecurity
        {
            get { return this._integratedSecurity; }
            set { _integratedSecurity = value; }
        }

        private string _sqlServerUsername;
        public string SqlServerUsername
        {
            get { return this._sqlServerUsername; }
            set { _sqlServerUsername = value; }
        }
        private string _SqlServerPassword;
        public string SqlServerPassword
        {
            get { return this._SqlServerPassword; }
            set { _SqlServerPassword = value; }
        }

        private bool _useDatabaseFile = false;
        public bool UseDatabaseFile
        {
            get { return this._useDatabaseFile; }
            set { _useDatabaseFile = value; }
        }

        private string _databaseFilePath = string.Empty;
        public string DatabaseFilePath
        {
            get { return this._databaseFilePath; }
            set { _databaseFilePath = value; }
        }

        public SqlScriptsOptions() { }

        public string GetConnectionString()
        {
            return string.Format(
                "{0}Integrated Security={1};{2}{3}{4}{5}{6}",
                (UseDatabaseFile) ? "Data Source=.\\SQLEXPRESS;" : string.Format("Data Source={0};", ServerName),
                IntegratedSecurity,
                (UseDatabaseFile) ?
                "" : string.Format("Initial Catalog={0};", DatabaseName),
                (IntegratedSecurity) ?
                "" : string.Format("uid={0};", SqlServerUsername),
                (IntegratedSecurity) ?
                "" : string.Format("pwd={0};", SqlServerPassword),
                (UseDatabaseFile) ?
                string.Format("AttachDbFilename={0};", DatabaseFilePath) :
                "",
                (UseDatabaseFile) ? "User Instance=True" : "");

            //for connecting to a file
            //Data Source=.\SQLEXPRESS;
            //AttachDbFilename="C:\Documents and Settings\justinc\My Documents\Visual Studio 2005\Projects\Magenic.Fbog\Magenic.Fbog.Test\TestDatabase.mdf";
            //Integrated Security=True;
            //User Instance=True

        }
    }
}
